<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>入库查询</title>

    <link rel="stylesheet" href="../css/pintuer.css">
    <link rel="stylesheet" href="../css/admin.css">
    <link rel="stylesheet" href="../css/bootstrap.css">

    <script src="../js/jquery-3.4.1.min.js"></script>
    <script src="../js/bootstrap-table1.15.3.js"></script>
    <script src="../js/bootstrap-table-zh-CN.min.js"></script>
    <script src="../js/popper.min.js"></script>
    <script src="../js/bootstrap.min.js"></script>
    <style>
        input{
            border-top: none;
            border-left: none;
            border-right: none;
            border-bottom: black solid 1px;
        }
        table{
            border: 1px;
            cell-padding:0;
            cell-spacing:0;
            width: 80%;
            margin-top: 20px;
        }
        table thead{
            background-color:#b3d7ff ;
        }
    </style>
</head>

<script>
    function initPutCheckInSelect(){
        $('#putCheckInSelectTableInfo').bootstrapTable(
            {
                //请求方式
                method:'post',
                contentType:'application/json',
                url:'/SGather/queryPutCheckInSelectAll.action',
                //设置交替样式
                striped:true,
                //初始显示页号
                pageNumber:1,
                //是否显示分页
                pagination:true,
                //是否设置服务端分页还是客户端分页
                sidePagination:'server',
                //页面大小
                pageSize:3,
                //分页列表
                pageList:[1,3,5,6,10],
                //上传到到服务端的参数
                queryParams:function (pares) {
                    return{
                        //计算页号（当前页）
                        pageNum:(pares.offset/pares.limit)+1,
                        //计算页大小
                        pageSize:pares.limit,
                    }
                },
                //第一列名
                columns:[
                    {title:"申请单编号",field:"gatherId",align:"center",formatter:function (value,row,index) {
                            return "<a href='#' onclick='queryPutAll("+JSON.stringify(row)+")' data-toggle='modal' data-target='#putCheckSelectModal'>"+value+"</a>"
                        }},
                    {title:"入库理由",field:"reason",align:"center",formatter:function (value,row,index) {
                            if(value=="R001-1"){
                                return "生产入库";
                            }else if(value=="R001-2"){
                                return "库存初始";
                            }else if(value=="R001-3"){
                                return "赠送";
                            }else if(value=="R001-4"){
                                return "内部归还";
                            }else if(value=="R001-5"){
                                return "其他归还";
                            }
                        }},
                    {title:"完成时间",field:"checkTime",align:"center",formatter:function (value,row,index) {
                            if(row.storeTag=='K002-2' || row.storeTag=='K002-1'){
                                return '<span style="size: 1em;color: red">------未审核------</span>';
                            }else {
                                return value;
                            }
                        }},
                    {title:"应入库总件数",field:"amountSum",align:"center"},
                    {title:"已入库总件数",field:"costPriceSum",align:"center"},
                    {title:"入库状态",field: "storeTag",align:"center",formatter:function (value,row,index) {
                            if(value == "K002-2"){
                                return "<span style='color: orange'>等待</span>"
                            }else if(value == "K002-1"){
                                return "<span style='color: red'>执行</span>"
                            }else if(value == "K002-3"){
                                return "<span style='color: blue'>完成</span>"
                            }
                        } }
                ]
            })
    }

    $(function () {
        initPutCheckInSelect();
    })
    
    function queryPutAll(rows) {

        $('#gatherId').text(rows.gatherId);
        $('#storer').text(rows.storer);

        $('#checker').text(rows.checker)

        $('#checkTime').text(rows.checkTime)

        let reason = rows.reason;
        if(reason=='R001-1'){
            reason='生产入库';
        }else if(reason=='R001-2'){
            reason='库存初始';
        }else if(reason=='R001-3'){
            reason='赠送';
        }else if(reason=='R001-4'){
            reason='内部借领';
        }else if(reason=='R001-5'){
            reason='其他借领';
        }
        $('#reason').text(reason);
        $('#amountSum').text(rows.amountSum);
        $('#costPriceSum').text(rows.costPriceSum);

        $('#tbodyId').empty();
        $.ajax({
            type:'post',
            url:'/sGatherDetails/querySGatherDetailsCheckInAll.action',
            data:'parentId='+rows.id,
            success:function (result) {
                let tbodyId = $('#tbodyId');
                $.each(result,function (i,res) {
                    let trObj = $('<tr>');
                    tbodyId.append(trObj);
                    trObj.append($('<td>').text(res.productId));
                    trObj.append($('<td>').text(res.productName));
                    //数量
                    trObj.append($('<td>').text('成品库'));
                    trObj.append($('<td>').text(res.sCell.firstKindName+"-"+res.sCell.secondKindName+"-"+res.sCell.thirdKindName));
                    trObj.append($('<td>').text(res.amount))
                    // trObj.append($('<td>').text(res.gatheredAmount))
                    trObj.append($('<td>').text(res.amount))
                })
            }
        });
    }

</script>

<body bgcolor="#f5f5f5">

<div class="container-fluid">
    <div style="width: 100%;margin: 0px;padding: 0px;">
        <table id="putCheckInSelectTableInfo" class="table table-bordered table-hover table-striped table-condensed">

        </table>
    </div>
</div>

<!--模态框-->
<!--modal fade-->
<div class="modal  fade" id="putCheckSelectModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <form id="updateSGatherFormId">
        <div class="modal-dialog" style="width: 90%">
            <div class="modal-content" style="border: 1px solid black;">
                <div class="modal-header">
                    <div class="container">
                        <div class="row">
                            <div class="col-7" style="text-align: right">
                                <h5 class="modal-title" id="info" >
                                    入库单信息
                                </h5>
                            </div>
                        </div>
                    </div>
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="margin-right: 0px">

                    </button>
                </div>
                <div class="modal-body">
                    <div class="container-fluid">
                        <div class="row" style="margin-top: 10px">
                            <div class="col-12">
                                <div class="container-fluid">
                                    <div class="row">
                                        <div class="col-4">
                                            入库单编号:
                                            <span id="gatherId"></span>
                                        </div>
                                    </div>
                                    <div class="row" style="margin-top: 30px;">
                                        <div class="col-4">
                                            入库理由：<span id="reason"></span>
                                        </div>
                                    </div>

                                    <div>
                                        <table border="1" cellpadding="0" cellspacing="0" width="80%" style="margin-top: 20px;" class="table table-sm">
                                            <thead  style="background-color: #b3d7ff;">
                                            <tr>
                                                <th>产品编号</th>
                                                <th>产品名称</th>
                                                <th>库存名称</th>
                                                <th>存放地址</th>
                                                <th>应入库件数</th>
                                                <!--                                                <th>已入库件数</th>-->
                                                <th>本次入库数量</th>
                                            </tr>
                                            </thead>
                                            <tbody id="tbodyId">

                                            </tbody>
                                        </table>
                                    </div>

                                    <div class="row" style="margin-top: 30px;">
                                        <div class="col-4">
                                            应入库总件数：<span id="amountSum"></span>
                                        </div>

                                        <div class="col-4 offset-2">
                                            应入库总金额：<span id="costPriceSum"></span>
                                        </div>

                                    </div>

                                    <!--<div class="row" style="margin-top: 30px;">
                                        <div class="col-3">
                                            已入库总件数：<span id="gatheredAmount">0</span>
                                        </div>

                                        <div class="col-3 offset-3">
                                            已入库总成本：<span id="subtotal">0</span>
                                        </div>
                                    </div>-->

                                    <div class="row" style="margin-top: 30px;">
                                        <div class="col-3">
                                            复核人：<span id="checker">0</span>
                                        </div>

                                        <div class="col-3 offset-3">
                                            复核时间：<span id="checkTime">0</span>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <!--<button type="button" class="btn btn-primary" id="putCountBtn">
                        复核通过
                    </button>-->
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </form>
</div>
</body>
</html>